﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WBrowser.MY_CODE
{
    public partial class TestLINQ : Form
    {
        List<string> urlKeywords;
        
        public TestLINQ(string url)
        {
            InitializeComponent();
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            DataSet ds = MITI.BaseDBCe.ExecSql_DataSet("select KeyName from KeyWords where KeyType = 4");

            urlKeywords = new List<string>();
            foreach (DataRow dr in ds.Tables[0].Rows)
                urlKeywords.Add(dr[0].ToString());

            var result = from x in urlKeywords
                         where "online.php".Contains(x)
                         select x;
            string test = "";
            foreach (string s in result)
            {
                test += s;
            }

            string[] Birds = { "Indigo Bunting", "Rose Breasted Grosbeak", "Robin", 
                               "House Finch", "Gold Finch", "Ruby Throated", 
                                "Hummingbird","Rufous Hummingbird", "Downy Woodpecker" 
                              };

            var list = from b in Birds
                       where b.StartsWith("R")
                       select b;
            int num = list.Count();
            StringBuilder sb = new StringBuilder();

            foreach (string s in list)
            {
                sb.Append(s + Environment.NewLine);
            }

            MessageBox.Show(sb.ToString(), "R Birds");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //DataTable orders = ds.Tables["SalesOrderHeader"];

            //var query =
            //    from order in orders.AsEnumerable()
            //    where order.Field<bool>("OnlineOrderFlag") == true
            //    select new
            //    {
            //        SalesOrderID = order.Field<int>("SalesOrderID"),
            //        OrderDate = order.Field<DateTime>("OrderDate"),
            //        SalesOrderNumber = order.Field<string>("SalesOrderNumber")
            //    };
        }
    }
}
